<!DOCTYPE html>
<html lang="en">
	<head>
		<meta charset="UTF-8">
		<meta http-equiv="X-UA-Compatible" content="IE=edge">
		<meta name="viewport" content="width=device-width, initial-scale=1.0">
		<title>发个信</title>
		<style>
			body {
				margin: 0;
				padding: 0;
			}

			.logo-box {
				height: 500px;
				display: flex;
				flex-direction: column;
				justify-content: center;
				align-items: center;
			}

			.footer {
				position: fixed;
				bottom: 0;
				left: 0;
				right: 0;
				width: 100%;
				height: 180px;
				text-align: center;
			}

			.btn {
				width: 280px;
				height: 40px;
				text-align: center;
				line-height: 40px;
				border-radius: 40px;
				margin: 20px auto;
				background: linear-gradient(-90deg, #FB8F51 60%, #FB8F51 100%);
				color: #fff;
			}

			.gray {
				background: #999;
			}

			.show-msg {
				width: 100%;
				height: 50px;
				background-color: #ff976a;
				color: #fff;
				border-bottom: 0.5px solid #efefef;
				position: fixed;
				top: -60px;
				display: flex;
				justify-content: center;
				align-items: center;
			}

			.show {
				transform: translateY(60px);
				transition: all 1s;
			}

			.banner {
				width: 100vw;
				height: 100vh;
				background-image: url("https://fgxfile.fagexin.online/fgx/1679394209551403.png");
				background-repeat: no-repeat;
				background-size: cover;
				background-position: center;
				background-color: #FFFFFF;
			}
		</style>
	</head>
	<body>
		<div class="banner">
			<div class="footer">
				<div class="btn" id="download">下载发个信</div>
				<div class="btn  gray" id="btn">打开发个信</div>
			</div>
			<div class="show-msg" id="msg">
				<div>点击右上角</div>
				<div style="margin-top:-20px;transform: scale(2);margin-left:10px;margin-right:10px;">...</div>
				<div>，用默认浏览器下载</div>
			</div>
		</div>

		<script>
			var download = document.getElementById("download")
			var btn = document.getElementById("btn")
			var ua = navigator.userAgent.toLowerCase(); //获取判断是否是微信浏览器
			var msg = document.getElementById("msg")
			var xhr = new XMLHttpRequest();
			var downloadUrl;
			xhr.open("get", "/chat/configList")
			xhr.send()
			xhr.onreadystatechange = function() {
				//   console.log(xhr.readyState);
				//0－未初始化，即尚未调用 open。
				//1－初始化，即尚未调用 send。
				//2－发送数据，即已经调用 send。
				//3－数据传送中。
				//4－完成。
				if (xhr.readyState === 4 && xhr.status === 200) {
					// console.log(xhr.responseText); //获得字符串的响应数据
					//responseXML  //获得 XML 形式的响应数据
					var {
						data
					} = JSON.parse(xhr.responseText);
					console.log(data);
					downloadUrl = data.ANDROID_DOWNLOAD_URL
				}
			};
			// 下载发个信
			download.addEventListener("click", (e) => {
				if (ua.match(/MicroMessenger/i) == "micromessenger") {
					msg.classList.add("show")
				} else {
					window.location.href = downloadUrl
				}
			})
			// 打开发个信
			btn.addEventListener("click", (e) => {
				// fagexin://aaa?path=/pages/login/login&invite=123456
				let params = window.location.search.replace("?", "&") //邀请码
				console.log('xxxxxxxxxxxx', "fagexin://aaa?path=/pages/login/login" + params);
				window.location.href = "fagexin://aaa?path=/pages/login/login" + params
			})


			if (ua.match(/MicroMessenger/i) == "micromessenger") {
				msg.classList.add("show")
			}
		</script>
	</body>
</html>